<?php
/*
 * @Author: 兰文涛1 810298819@qq.com
 * @Date: 2024-06-30 23:16:01
 * @LastEditors: 兰文涛1 810298819@qq.com
 * @LastEditTime: 2024-07-01 00:01:20
 * @FilePath: \cloud_learn\insert.php
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
require_once("./db/conn.php");

$content = $_POST['content'];

// 这里假设数据库表名为 posts，包括字段 course_id 和 content
$sql = "INSERT INTO post (course_id, content, publish_time, publisher, user_id) VALUES ('9','$content',NOW(), 'bob', '1')";

if (mysqli_query($conn, $sql)) {
    // 插入成功，返回 "success"
    echo "success";
} else {
    // 插入失败，返回 "error"
    echo "error";
}

mysqli_close($conn);
?>